package com.cl.mypureframe;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;

import com.cl.mypureframe.util.GLobalConstant;
import com.cl.mypureframe.util.UtilMD5;


/**
 * SP
 * Created by Lei on 2020/11/18.
 */
public class BasePreferences {
    private final SharedPreferences b;
    private final SharedPreferences.Editor a;

    @SuppressLint("CommitPrefEdits")
    public BasePreferences() {
        b = BaseApplication.INSTANCE.getSharedPreferences(
                UtilMD5.MD5Encode(GLobalConstant.PROJECT_NAME, "UTF-8"), Context.MODE_PRIVATE);
        a = b.edit();
    }

    public void saveIsGuide(boolean isGuide) {

        a.putBoolean("isGuide", isGuide).commit();

    }

    public boolean readIsGuide() {

        return b.getBoolean("isGuide", false);

    }

    // 存储上一次用户登录名
    public void putLastLoginAccount(String loginAccount) {
        a.putString("loginaccount", loginAccount).commit();
    }

    // 获取上一次用户登录名
    public String getLastLoginAccount() {
        return b.getString("loginaccount", null);
    }

    // 存储用户ID
    public void putUserId(String userid) {
        a.putString("userid", userid).commit();
    }

    // 获取用户ID
    public String getUserId() {
        return b.getString("userid", GLobalConstant.USERID);
    }

    // 存储用户名称
    public void putUserName(String name) {
        a.putString("uname", name).commit();
    }

    // 获取用户名称
    public String getUserName() {
        return b.getString("uname", "用户");
    }

    // 存储手机号
    public void putPhonenum(String pnum) {
        a.putString("pnum", pnum).commit();
    }

    // 获取手机号
    public String getPhonenum() {
        return b.getString("pnum", "0");
    }

    // 存储 经度
    public void putLongitude(String lon) {
        a.putString("longitude", lon).commit();
    }

    // 获取 经度
    public String getLongitude() {
        return b.getString("longitude", null);
    }

    // 存储 纬度
    public void putLatitude(String lat) {
        a.putString("latitude", lat).commit();
    }

    // 获取 纬度
    public String getLatitude() {
        return b.getString("latitude", null);
    }


}